package com.cn.wanxi.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.entity.SortEntity;
import com.cn.wanxi.service.ISortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
@RequestMapping("/back/sort")
public class SortController {

    @Autowired
    private ISortService iSortService;

    public void findAll(HttpServletResponse resp) throws IOException {

        List<SortEntity> list = iSortService.findAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list",list);
        resp.getWriter().println(jsonObject);
    }

    @RequestMapping("/findAll")
    @ResponseBody
    public void productPage(HttpServletResponse resp) throws IOException {

        List<SortEntity> list = iSortService.getSort();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list",list);
        resp.getWriter().println(jsonObject);
    }

}

